package org.rc.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import org.rc.dto.RoleAddDto;
import org.rc.dto.RoleUpdateDto;

import java.time.LocalDateTime;

@Data
public class Role {
    @TableId(value = "id",type = IdType.AUTO)
    private Long id;

    private String name;

    private String createdBy;

    private LocalDateTime createdTime;


    public static Role getInstance(RoleAddDto roleAddDto){
        Role role = new Role();
        role.setName(roleAddDto.getRoleName().trim());
        role.setCreatedBy("admin");
        role.setCreatedTime(LocalDateTime.now());
        return role;
    }

    public static Role getInstance(RoleUpdateDto roleUpdateDto){
        Role role = new Role();
        role.setId(roleUpdateDto.getId());
        role.setName(roleUpdateDto.getRoleName().trim());
        role.setCreatedBy("admin");
        role.setCreatedTime(LocalDateTime.now());
        return role;
    }

}
